-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add lint print_stderr #6367
Add lint print_stderr #6367
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ebroto (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
☔ The latest upstream changes (presumably #6389) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the phrasing in PRINT_STDOUT
documentation, it seems targetting only print
and println
was intended, so I think it's OK to have a separate lint for eprint
and eprintln
.
clippy_lints/src/write.rs
Outdated
@@ -260,6 +279,10 @@ impl EarlyLintPass for Write { | |||
); | |||
} | |||
} | |||
} else if mac.path == sym!(eprintln) { | |||
span_lint(cx, PRINT_STDERR, mac.span(), "use of `eprintln!`"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the surrounding code and the description of those lints, it seems PRINTLN_EMPTY_STRING
and PRINT_WITH_NEWLINE
could apply to eprintln
and eprint
respectively.
Would you mind doing that change in this PR? Alternatively we can open a different issue and leave it as a follow-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The application of PRINTLN_EMPTY_STRING
and PRINT_WITH_NEWLINE
to eprintln
and eprint
would also require giving different suggestions for each case (using eprint[ln]
instead of print[ln]
). Should these be divided into separate lints as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this change!
No, I think we just need to change the suggestion depending on the case, but without adding new lints.
BTW it seems you need to rebase on top of the master branch, there are a lot of commits that are not related to this PR. Do not hesitate to ping me if you find any problem when doing that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ebroto It seems I have made a mess of the branch's history. I don't know enough git to deal with this. I've tried rebasing several times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justjosias it should be fixed now.
FYI I did an interactive rebase on top of the current master, which left 4 commits. 2 of them were duplicates, so I only kept the newest ones and fixed some conflicts during the rebase.
BTW do not forget to commit the changes to the stderr
file; since we added some lines, the line numbers of the previous error messages has changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ebroto It appears master no longer compiles, so I can't test anything or proceed with other changes. But I fixed the stderr
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justjosias FYI the problem you mention has been fixed, it should work if you 1) re-run setup-toolchain.sh
and 2) rebase on top of the latest master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I screwed up the history again. I'll figure out the interactive rebase to fix it.
EDIT: Fixed! Thanks for the advice. I'm now going to work on this last change.
b2380f6
to
e080791
Compare
c33fc5a
to
e59cbbb
Compare
Resolves rust-lang#6348 Almost identical to print_stdout, this lint applies to the `eprintln!` and `eprint!` macros rather than `println!` and `print!`.
Get rid of the too-many-lines error.
f2952db
to
3187cad
Compare
FYI the CI error was related to a function having too many lines in Thanks for your contribution and don't hesitate to take another issue :) |
@bors r+ |
📌 Commit 3187cad has been approved by |
Add lint print_stderr Resolves #6348 Almost identical to print_stdout, this lint applies to the `eprintln!` and `eprint!` macros rather than `println!` and `print!`.
💔 Test failed - checks-action_test |
@bors retry (missing changelog) |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Resolves #6348
Almost identical to print_stdout, this lint applies to the
eprintln!
andeprint!
macros rather thanprintln!
andprint!
.changelog: Add new lint [
print_stderr
]. [println_empty_string
] and [print_with_newline
] now apply toeprint!()
andeprintln!()
respectively.